﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using XLua;

[CSharpCallLua]
public interface ITestInClass
{
    bool testBool
    {
        get;
        set;
    }
}

[CSharpCallLua]
public interface CallInterface
{
    int testInt
    {
        get;
        set;
    }
     float testFloat    
     {
         get;
         set;
     }
     bool testBool    
     {
         get;
         set;
     }
     string testString    
     {
         get;
         set;
     }
     UnityAction testFunc    
     {
         get;
         set;
     }
     UnityAction<CallInterface> testFunc2    
     {
         get;
         set;
     }
     /*TestInClass testInClass    
     {
         get;
         set;
     }*/
     ITestInClass testInClass    
     {
         get;
         set;
     }
}
public class Lesson8_CallInterface : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        LuaMgr.GetInstance().Init();
        LuaMgr.GetInstance().DoLuaFile("Main");
        
        CallInterface testClass = LuaMgr.GetInstance().Global.
            Get<CallInterface>("testClass");
        
        Debug.Log("____________________________");
        Debug.Log(testClass.testBool);
        Debug.Log(testClass.testFloat);
        testClass.testFunc();
        testClass.testFunc2(testClass);
        Debug.Log(testClass.testInClass.testBool);

        testClass.testFloat = 999.1f;
        testClass.testInClass.testBool = true;
        
        CallInterface testClass2 = LuaMgr.GetInstance().Global.
            Get<CallInterface>("testClass");
        
        Debug.Log("____________________________");
        Debug.Log(testClass2.testFloat);
        Debug.Log(testClass2.testInClass.testBool);
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
